package com.kyivmohyla.kma2.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.kyivmohyla.kma2.client.exception.DelistedException;
import com.kyivmohyla.kma2.shared.model.UIStaff;

@RemoteServiceRelativePath("LoginService")
public interface LoginService extends RemoteService {

    UIStaff getByLoginAndPassword(String email, String password) throws DelistedException;

    void login(UIStaff staff);

    UIStaff checkLogin();

    void logout();

    /**
     * Utility/Convenience class.
     * Use LoginService.App.getInstance() to access static instance of LoginServiceAsync
     */
    public static class App {
        private static final LoginServiceAsync ourInstance = (LoginServiceAsync) GWT.create(LoginService.class);

        public static LoginServiceAsync getInstance() {
            return ourInstance;
        }
    }
}
